.TH std::ostrstream::~ostrstream 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ostrstream::~ostrstream \- std::ostrstream::~ostrstream

.SH Synopsis
   virtual ~ostrstream();  (deprecated in C++98)
                           (removed in C++26)

   Destroys a std::ostrstream object, which also destroys the member std::strstreambuf,
   which may call the deallocation function if the underlying buffer was
   dynamically-allocated and not frozen.

.SH Parameters

   \fI(none)\fP

.SH Notes

   If str() was called on a dynamic ostrstream and freeze(false) was not called after
   that, this destructor leaks memory.

.SH Example


// Run this code

 #include <iostream>
 #include <strstream>

 int main()
 {
     {
         std::ostrstream s; // dynamic buffer
         s << 1.23;
         std::cout << s.str() << '\\n';
         s.freeze(false);
     } // destructor called, buffer deallocated

     {
         std::ostrstream s;
         s << 1.23;
         std::cout << s.str() << '\\n';
 //      buf.freeze(false);
     } // destructor called, memory leaked
 }

.SH Output:

 1.23
 1.23
